# AUTHOR: DING
# -*- codeing = utf-8 -*-
# @Time: 2024/2/23 18:51
# @Author: 86139
# @Site: 
# @File: 16-sequential.py
# @Software: PyCharm
# tensorboard --logdir=pytorch/logs --port=6007
from collections import OrderedDict

import torch
import torch.nn as nn
import torchvision
from torch.utils.tensorboard import SummaryWriter

dataset = torchvision.datasets.CIFAR10("./dataset", train=False, transform=torchvision.transforms.ToTensor(),
                                       download=True)


class MyModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.model1 = nn.Sequential(
            nn.Conv2d(3, 32, (5, 5), padding=2),
            nn.MaxPool2d(2),
            nn.Conv2d(32, 32, (5, 5), padding=2),
            nn.MaxPool2d(2),
            nn.Conv2d(32, 64, (5, 5), padding=2),
            nn.MaxPool2d(2),
            nn.Flatten(),
            nn.Linear(1024, 64),
            nn.Linear(64, 10))
        self.model2 = nn.Sequential(OrderedDict([
            ('conv1', nn.Conv2d(3, 32, (5, 5), padding=2)),
            ('pool1', nn.MaxPool2d(2)),
            ('conv2', nn.Conv2d(32, 32, (5, 5), padding=2)),
            ('pool2', nn.MaxPool2d(2)),
            ('conv3', nn.Conv2d(32, 64, (5, 5), padding=2)),
            ('pool3', nn.MaxPool2d(2)),
            ('flat', nn.Flatten()),
            ('linear', nn.Linear(1024, 64)),
            ('linear2', nn.Linear(64, 10)),
        ]))

    def forward(self, x):
        return self.model2(x)


module = MyModule()
input = torch.ones(64, 3, 32, 32)
output = module(input)
print(output)

writter = SummaryWriter("./logs")
writter.add_graph(module, input)
writter.close()
